package com.zmm.weblog.admin.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zmm.weblog.admin.convert.BlogSettingsConvert;
import com.zmm.weblog.admin.model.vo.blog.FindBlogSettingsRspVO;
import com.zmm.weblog.admin.model.vo.blog.UpdateBlogSettingReqVo;
import com.zmm.weblog.admin.service.AdminBlogService;
import com.zmm.weblog.common.domain.dos.BlogSettingsDo;
import com.zmm.weblog.common.domain.mapper.BlogSettingsMapper;
import com.zmm.weblog.common.utils.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author:福禄寿
 * @Date:2024/5/9 下午9:03
 * @Des:weblog-springboot
 **/
@Service
@Slf4j
public class AdminBlogServiceImpl extends ServiceImpl<BlogSettingsMapper, BlogSettingsDo>implements AdminBlogService {

    @Autowired
    private BlogSettingsMapper blogSettingsMapper;

    @Override
    public Response updateSettingBlog(UpdateBlogSettingReqVo blogSettingReqVo) {

        //VO转DO
       BlogSettingsDo blogSettingsDO = BlogSettingsConvert.INSTANCE.convertVO2DO(blogSettingReqVo);
       blogSettingsDO.setId(1L);
       saveOrUpdate(blogSettingsDO);
        return Response.success();
    }

    @Override
    public Response detailSettingBlog() {

        BlogSettingsDo blogSettingsDO = blogSettingsMapper.selectById(1L);
        FindBlogSettingsRspVO vo = BlogSettingsConvert.INSTANCE.convertDO2VO(blogSettingsDO);
        return Response.success(vo);
    }



        // 成员变量
        int memberVariable ; // 实例成员变量
        static String staticMemberVariable = "Hello"; // 静态成员变量

        // 成员方法展示成员变量和局部变量的使用
        public void showVariables() {
            // 局部变量
            int localVariable = 20;

            String a = "hello";

            // 访问和修改成员变量和使用局部变量
            System.out.println("成员变量 memberVariable 的值: " + memberVariable);
            System.out.println("静态成员变量 staticMemberVariable 的值: " + staticMemberVariable);
            System.out.println("局部变量 localVariable 的值: " + localVariable);

            // 改变成员变量的值
            memberVariable = 30;
            staticMemberVariable = "World";

            // 再次输出，展示成员变量值的变化
            System.out.println("修改后成员变量 memberVariable 的值: " + memberVariable);
            System.out.println("修改后静态成员变量 staticMemberVariable 的值: " + staticMemberVariable);
        }

        public static void main(String[] args) {
            // 创建对象并调用方法
            AdminBlogServiceImpl demo = new AdminBlogServiceImpl();
            demo.showVariables();

            // 直接访问静态成员变量，无需实例化对象
            System.out.println("直接访问静态成员变量 staticMemberVariable 的值: " + staticMemberVariable);
        }

}
